FROM node:18-alpine AS builder

ARG ENV="uat"

COPY . /src

WORKDIR /src

RUN npm i &&\
    npm run build:${ENV}


FROM --platform=linux/amd64 nginx:alpine

ARG ENV="uat"

COPY --from=builder /src/config/${ENV}/default.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /src/config/${ENV}/nginx.conf /etc/nginx/nginx.conf

COPY --from=builder /src/dist /usr/share/nginx/html



EXPOSE 80
CMD ["nginx", "-g", "daemon off;", "-c", "/etc/nginx/nginx.conf"]